﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="xbrlesita_myygitulu_rida", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(XbrlesitaMyygituluRida))]
    public class XbrlesitaMyygituluRidaSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IXbrlesitaMyygituluRida clazz;
        
        public XbrlesitaMyygituluRidaSerializer(IXbrlesitaMyygituluRida clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("emtak_kood");
            if (clazz.EmtakKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EmtakKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EmtakKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("emtak_versioon");
            if (clazz.EmtakVersioon!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EmtakVersioon))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EmtakVersioon");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("tulu");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Tulu))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("tulu_protsent");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.TuluProtsent))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("pohitegevus");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.Pohitegevus))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="emtak_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_myygitulu_rida>emtak_kood");
                }
                clazz.EmtakKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("emtak_kood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_myygitulu_rida>emtak_kood", Reader.LocalName);
            }
            if (Reader.LocalName=="emtak_versioon") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_myygitulu_rida>emtak_versioon");
                }
                clazz.EmtakVersioon = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("emtak_versioon")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_myygitulu_rida>emtak_versioon", Reader.LocalName);
            }
            if (Reader.LocalName=="tulu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_myygitulu_rida>tulu");
                }
                clazz.Tulu = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("tulu")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_myygitulu_rida>tulu", Reader.LocalName);
            }
            if (Reader.LocalName=="tulu_protsent") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_myygitulu_rida>tulu_protsent");
                }
                clazz.TuluProtsent = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("tulu_protsent")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_myygitulu_rida>tulu_protsent", Reader.LocalName);
            }
            if (Reader.LocalName=="pohitegevus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_myygitulu_rida>pohitegevus");
                }
                clazz.Pohitegevus = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("pohitegevus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_myygitulu_rida>pohitegevus", Reader.LocalName);
            }
        }
    }
}
